﻿Imports System.Windows.Forms
Public Class ucManu
    Private ManuID As Integer
    Public Function ucValidateManu() As Boolean
        If txtManuName.Text.Length = 0 Then
            MessageBox.Show("Bạn vui lòng điền đầy đủ thông tin!!")
            txtManuName.Focus()
            Return False
        End If
        If txtManuEmail.Text Like "*@[A-Z,a-z,0-9]*.*" Then
            Return True
        Else
            MessageBox.Show("Địa chỉ Email không đúng định dạng!!")
            txtManuEmail.Text = ""
            txtManuEmail.Focus()
            Return False
        End If
        If txtPhone.Text Like "[0-9]" Then
            Return True
        Else
            MessageBox.Show("Số điện thoại không đúng định dạng!!")
            txtPhone.Text = ""
            txtPhone.Focus()
            Return False
        End If
        Return True
    End Function
    Public Sub SetManufacturer(ByVal manu As eManufacturer)
        txtManuAdd.Text = manu.ContactAddress
        txtManuEmail.Text = manu.ContactEmail
        txtManuName.Text = manu.ManufacturerName
        txtPhone.Text = manu.ContactPhone
        ManuID = manu.ManufacturerID
    End Sub
    Public Function GetManufacturer() As eManufacturer
        Dim man As eManufacturer = New eManufacturer()
        man.ContactPhone = txtPhone.Text
        man.ContactEmail = txtManuEmail.Text
        man.ContactAddress = txtManuAdd.Text
        man.ManufacturerName = txtManuName.Text
        man.ManufacturerID = ManuID
        Return man
    End Function

    Public Sub ClearText()
        For Each c As Control In grpManu.Controls
            If (TypeOf c Is TextBox) Then
                c.ResetText()
            End If
        Next
    End Sub
End Class
